<template>
  <div class="Admin">
    <el-container>
      <el-aside width="220px">
        <el-row class="tac">
          <el-col :span="24">
            <el-menu
              default-active="1-0"
              class="el-menu-vertical-demo"
              @open="handleOpen"
              @close="handleClose"
            >
              <el-submenu
                :index="String(index)"
                v-for="(item, index) in leftMenu"
                :key="index"
              >
                <template slot="title">
                  <i class="el-icon-location"></i>
                  <span>{{ item.meta.name }}</span>
                </template>
                <el-menu-item-group>
                  <template v-for="(childItem, childIndex) in item.children">
                    <el-menu-item
                      v-if="childItem.meta.leftNav"
                      :index="index + '-' + childIndex"
                      :key="index + '-' + childIndex"
                      @click="routerPush(childItem.name)"
                      >{{ childItem.meta.name }}</el-menu-item
                    >
                  </template>
                </el-menu-item-group>
              </el-submenu>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import children from "../../router/admin/children";
export default {
  name: "Admin",
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    routerPush(routerName) {
      this.$router.push({
        name: routerName,
      });
    },
  },

  computed: {
    leftMenu() {
      return children;
    },
  },
};
</script>

<style lang="scss">
.el-aside {
  background: #ddd;
  height: 100vh;
}

.el-main {
}
</style>
